package com.arron.algorithm;


import java.util.HashSet;
import java.util.Set;

/**
 * @Classname Testshuz
 * @Date 2020/9/22 19:03
 * @Created by 刘
 *
 */
public class Testshuz {

    public static void main(String[] args) {
        //[1,2,3,4,5,6,7,8,9],2
        int[] a = {1,2,3,4,5,6,7,8,9};
        Testshuz testshuz = new Testshuz();
        testshuz.pushIntArray(a,2);
    }

    /**
     * 数组内数据循环平移
     * @param arr int整型一维数组 输入数组
     * @param pushOffset int整型 位移长度
     * @return int整型一维数组
     */
    public int[] pushIntArray (int[] arr, int pushOffset) {
        // write code here
        int length = arr.length;
        //用于记录最后一个元素
        int last = 0;
        while (pushOffset>0){
            for (int i = 0; i < length; i++) {
                //记录最后一个元素
                last = arr[length-1];
                arr[length-1] = arr[i];
                arr[i]=last;
            }
            --pushOffset;
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
        return null;
    }




}
